feat: add permission handler API across webview backends#1654
Conversation
Package Changes Through e7c84dcThere are 1 changes which include wry with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
56cc0d1 to
755877e
Compare
pewsheen
left a comment
There was a problem hiding this comment.
I currently only have a MacBook, so I'll share some thoughts about the macOS implementation here. For WebView2, maybe @Legend-Master can give some advice?
Personally, I tend not to loosen permission controls, to avoid them being used for malicious purposes.
Legend-Master
left a comment
There was a problem hiding this comment.
Looks good for the webview2 implementation at least at a glance, awesome work!
Could you also add a change file?
https://github.com/tauri-apps/wry/blob/dev/.changes/readme.md
Legend-Master
left a comment
There was a problem hiding this comment.
The webview2 code looks good to me and works well when tested on my computer, just a few small nitpicks, you might need to wait for other members to give some feedbacks on other platforms though
Also, you'll need to sign your commits before we can merge them
6a52c11 to
7aae5c4
Compare
pewsheen
left a comment
There was a problem hiding this comment.
macOS implementation looks good to me. Only a nit that I think we can improve.
Legend-Master
left a comment
There was a problem hiding this comment.
And you'll need to sign your commits
https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
28c368b to
bad81dd
Compare
Done. The commit is now digitally signed with an SSH key. |
bad81dd to
2f0df9e
Compare
fa4bba7 to
8ccc02e
Compare
pewsheen
left a comment
There was a problem hiding this comment.
wkwebview looks good to me 👍 . Let's see if there's something that needs to be discussed in other platform.
…n handler API, fix combined camera and microphone logic on macOS, update documentation to clarify NFC and Bluetooth support, and simplify permission_handler example using permission.site
33d810e to
b9d86ef
Compare
|
Updated this PR against latest The Android permission handling is still scoped per webview, and the checks are green again. I also updated the linked Tauri PR to use the new Wry commit. @FabianLars could you take another look at the Android part when you have time? |
aa2a5a9 to
26ca4b5
Compare
|
Sorry for the force push, I couldn't figure out how to fix the previous bugged merge without it |
Legend-Master
left a comment
There was a problem hiding this comment.
Thanks again for the incredible patience and awesome work!
Description
This PR adds a unified Permission Handler API for intercepting webview permission requests across WebView2, WKWebView, WebKitGTK, and Android.
The API lets applications decide how to handle permission requests at runtime by returning
Allow,Deny, orDefaultfrom a newWebViewBuilder::with_permission_handlercallback.Defaultfalls back to the platform or browser default behavior instead of forcing an explicit prompt. This keeps the API portable across backends where prompt/default handling is exposed differently.Key Changes
WebViewBuilder::with_permission_handler.PermissionKindfor webview permission categories such as camera, microphone, geolocation, notifications, display capture, MIDI, local fonts, file system access, autoplay, and more.PermissionResponsewithAllow,Deny, andDefault.permission_handlerexample using permission.site.Platform Implementations
Windows (WebView2)
PermissionRequestedevents.PermissionKind.AllowandDeny;Defaultleaves WebView2 default handling in place.macOS / iOS (WKWebView)
requestMediaCapturePermission.PermissionKind.Defaultto WebKit's prompt/default permission flow.CameraAndMicrophonerequests by checking camera and microphone separately, with deny taking precedence.Linux (WebKitGTK)
permission-requestsignal.is_for_display_device()with thev2_42feature and falls back to display-capture detection for older WebKitGTK versions.Default, so WebKitGTK can apply its default behavior.Android
WebChromeClient.onPermissionRequestand geolocation permission prompts through JNI.Denyrejects the Android request;AllowandDefaultcontinue the normal Android runtime permission flow.Example